<?php
/**
 * Created by PhpStorm.
 * User: win7
 * Date: 2018/6/13 0013
 * Time: 14:28
 */

namespace Wx\Controller;


use Think\Controller;

class ProductController extends Controller
{
    public function index(){
        $spellgroup_model = M("shop_spellgroup");
        $area_info = $spellgroup_model->where("state = 1 AND a_id_1 != 0")->group('a_id_1')->field("a_id_1 as id")->select();//获取省份id

        foreach($area_info as $k => $v){
            $area_id[] = $v['id'];
        }//end foreach //id处理

        foreach($area_id as $k => $v){
            $classify[$v] = $spellgroup_model->where("state = 1 AND a_id_1 = {$v} AND type_name != ''")->group('type_name')->field("type_name")->limit(8)->select();//获取地标商品分类
        }//end foreach //分类列表
//        dump($classify);
        $this->assign('classify',$classify);
        $this->display('product');
    }//end fun

    public function more(){
        $area_id = $_GET['aid'];//省份id
        $classify = M("shop_spellgroup")->where("state = 1 AND a_id_1 = {$area_id} AND type_name != ''")->group('type_name')->field("type_name")->select();//获取地标商品分类

        $this->assign('area_id',$area_id);
        $this->assign('classify',$classify);
        $this->display();
    }//end fun
}//end class